package springboot.service.impl;

import org.springframework.stereotype.Service;
import springboot.dao.WxGroupDao;
import springboot.doMain.WxGroup;
import springboot.service.WXGroupService;

import java.util.List;

/**
 * wxWork
 * springboot.service.impl
 * Created by Blue on 2021/9/26.
 */

@Service
public class WXGroupServiceImpl implements WXGroupService {
	
	final
	WxGroupDao wxGroupDao;
	
	public WXGroupServiceImpl(WxGroupDao wxGroupDao) {
		this.wxGroupDao = wxGroupDao;
	}
	
	@Override
	public int deleteByPrimaryKey(Long id) {
		return 0;
	}
	
	@Override
	public int insert(WxGroup record) {
		if (record == null) {
			return -1;
		}
		WxGroup wxGroups = wxGroupDao.selWxGroupByChatId(record);
		try {
			if (wxGroups == null) {
				return wxGroupDao.insert(record);
			} else {
				if (wxGroups.isEquals(record)) {
					return 0;
				}
				return wxGroupDao.updateWxGroup(record);
			}
		} catch (Exception e) {
			System.err.println("e1111 = " + e);
			return -1;
		}
	}
	
	@Override
	public int insertSelective(WxGroup record) {
		return 0;
	}
	
	@Override
	public int selAllGroupCnt() {
		return wxGroupDao.selAllGroupCnt();
	}
	
	@Override
	public WxGroup selWxGroupByChatId(WxGroup wxGroup) {
		return wxGroupDao.selWxGroupByChatId(wxGroup);
	}
	
	@Override
	public int updateWxGroup(WxGroup wxGroup) {
		return 0;
	}
	
	@Override
	public List<WxGroup> selAllWxGroup() {
		return null;
	}
	
	
	@Override
	public int updateByPrimaryKey(WxGroup record) {
		return 0;
	}
}
